package dao

import (
	"zy4/global"
	"zy4/internal/model"
)

func CreateUser(user *model.User) bool {
	if err := global.DB.Create(&user).Error; err != nil {
		return false
	}
	return true
}
func GetUserMobile(mobile string) model.User {
	var result model.User
	err := global.DB.Where("mobile = ?", mobile).Find(&result).Error
	if err != nil {
		return model.User{}
	}
	return result
}

func GetUserMobileAndPassword(mobile string, password string) model.User {
	var result model.User
	err := global.DB.Where("mobile = ?", mobile).Where("password = ?", password).Find(&result).Error
	if err != nil {
		return model.User{}
	}
	return result
}
